package com.dh.lc.server;

import com.dh.lc.client.GreetingService;
import com.dh.lc.dao.CoderDAO;
import com.dh.lc.mo.Coder;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
		GreetingService {

	public String greetServer(String input) {
		String serverInfo = getServletContext().getServerInfo();
		String userAgent = getThreadLocalRequest().getHeader("User-Agent");
		
		
		CoderDAO coderDao = new CoderDAO();
		Coder coder = new Coder();
		coder.setNickName("dahui");
		coder.setFirstName("firstName");
		coder.setLastname("abc");
		coderDao.addCoder(coder);
		
		long coderAmount = coderDao.getCoderAmount();
		
		return coderAmount + "Hello, " + input + "!<br><br>I am running " + serverInfo
				+ ".<br><br>It looks like you are using:<br>" + userAgent;
	}
}
